from cart.services.cart import Cart
from order.models import OrderItem


class Order(object):

    def __init__(self, request):

        self.request = request

    def place_order(self, created_order):

        """ Оформляем заказ пользователя """

        cart = Cart(self.request)

        for item in cart:
            OrderItem.objects.create(order=created_order,
                                     product=item['product'],
                                     price=item['price'],
                                     quantity=item['quantity'])
        cart.clear() 
